package com.game.view.layer
{
	import com.game.view.ViewerBase;
	
	import flash.display.DisplayObject;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	
	public class LayerBase extends ViewerBase
	{
		
		public function LayerBase()
		{
			super();
			this.tabEnabled = false;
			this.tabChildren = false;
		}
		
		public function setCloseBtn(obj:DisplayObject):void
		{
			if(obj is Sprite)
			{
				(obj as Sprite).buttonMode = true;
				(obj as Sprite).mouseEnabled = true;
				(obj as Sprite).addEventListener(MouseEvent.CLICK, removeFromParent, false, 0, true);
			}
			else if(obj is SimpleButton)
			{
				(obj as SimpleButton).addEventListener(MouseEvent.CLICK, removeFromParent, false, 0, true);
			}
			else if (obj is TextField)
			{
				(obj as TextField).addEventListener(MouseEvent.CLICK, removeFromParent, false, 0, true);
			}
			else
			{
				throw new Error("未知的元件类型");
			}
		}
	}
}
